// source --> https://naturliggas.dk/wp-content/plugins/vivodaresursbankhostedflow/js/vivodaresursbank.js?ver=4.9.5 /** * @Module Name: Resursbank * @Website: Vivoda.dk && Tael.pl * @author Vivoda.dk * @author Tael.pl * @copyright 2007-2017 Vivoda.dk && Tael.pl */ function informatinAboutPayment(url, title) { if (typeof bootbox.dialog != "undefined") { data = jQuery.get(url, function (data) { var resursdialog = bootbox.dialog({ title: title, message: data }); }); return false; } } function informatinAboutPaymentDirect(url, title) { if (typeof bootbox.dialog != "undefined") { var resursdialog = bootbox.dialog({ title: title, message: '

Loading...

' }); resursdialog.init(function () { setTimeout(function () { resursdialog.find('.bootbox-body').html( '' ); }, 1000); }); return false; } } prices = {}; prices_html = {}; RBsummaryloading = false; RBproductloading = false; (function ($) { $(document).ready(function () { setTimeout(function () { if ($('.rblazy').length > 0) { if ($(".rblazy:hidden").length > 0) { $(".rblazy:hidden").each(function(){ $(this).parent().after($(this)); // $.lazyload.check(); }); } $('.rblazy').lazyload({ threshold: 100, load: function (element) { console.log(element.data("price")); getProductCostOfPurchaseOneByOne(element.data("price")); }, trigger: "appear" }); } }, 1000); if (ajax_resurs_object.show_on_cart) { $('.cart-collaterals, .cart_totals, .dropdown-cart').bind("DOMSubtreeModified", function () { if (RBsummaryloading === false) { RBsummaryloading = true; getTotalCostOfPurchase(); } }); } if (ajax_resurs_object.show_on_product) { var var_classes = ".variations, .price-container"; if ($(var_classes).length > 0) { console.log("binding"); $(var_classes).bind("DOMSubtreeModified", function () { console.log("changing..."); setTimeout( function () { $temp = $(".woocommerce-variation-price .price .woocommerce-Price-amount, .normal-price-container .price .woocommerce-Price-amount").clone(); $temp.find("span").remove(); new_price = parseFloat($temp.text().replace(ajax_resurs_object.currencySign, "").replace(ajax_resurs_object.thousand_separator, "").replace(ajax_resurs_object.decimal_separator, ".")); if(!isNaN(new_price)){ if ($(".summary .rbpricetag").attr('data-price') != new_price) { $(".summary .rbpricetag").addClass("pricechanged").attr('data-price', new_price); getProductCostOfPurchase(); } } }, 1000); }); } $(".quantity").bind("change", function () { var qty = $(".qty").val(); $temp = $(".summary .price .woocommerce-Price-amount").clone(); $temp.find("span").remove(); var new_price = parseFloat($temp.text().replace(ajax_resurs_object.currencySign, "").replace(ajax_resurs_object.thousand_separator, "").replace(ajax_resurs_object.decimal_separator, ".")) * qty; if ($(".woocommerce-variation-price").length > 0) { $temp = $(".woocommerce-variation-price .price .woocommerce-Price-amount").clone(); $temp.find("span").remove(); new_price2 = parseFloat($temp.text().replace(ajax_resurs_object.currencySign, "").replace(ajax_resurs_object.thousand_separator, "").replace(ajax_resurs_object.decimal_separator, ".")); if (new_price2 != 0) { new_price = new_price2; } } // console.log($temp.text().replace(ajax_resurs_object.currencySign, "").replace(ajax_resurs_object.thousand_separator, "").replace(ajax_resurs_object.decimal_separator, ".")); if(!isNaN(new_price)){ if ($(".summary .rbpricetag").attr('data-price') != new_price) { $(".summary .rbpricetag").addClass("pricechanged").attr('data-price', new_price); getProductCostOfPurchase(); } } }); } setTimeout(function () { // give some time for other elemets to load getTotalCostOfPurchase(); getProductCostOfPurchase(); }, 1000); }) })(jQuery); function bindRBpopup(classdesc) { (function ($) { $('.popover').popover('hide'); $(".popover").remove(); $(classdesc).each(function () { var trigger = $(this); trigger.on('click', function (e) { e.preventDefault(); }); trigger.popover({ trigger: "manual", animation: false, animation: true, delay: {show: 0, hide: 0}, html: true, container: 'body', placement: getPlacementFunction(trigger.attr("data-placement"), 450, 450) }) .on("click", function () { var _this = this; $(this).popover("show"); $(".popover").on("mouseleave", function () { $(_this).popover('hide'); }); }) .on("mouseenter", function () { var _this = this; $(this).popover("show"); $(".popover").on("mouseleave", function () { $(_this).popover('hide'); }); }) .on("mouseleave", function () { var _this = this; setTimeout(function () { if (!$(".popover:hover").length) { $(_this).popover("hide"); } }, 300); }); }); })(jQuery); } function getTotalCostOfPurchase() { (function ($) { RBsummaryloading = true; $('.RBsummary').remove(); if (ajax_resurs_object.show_on_cart && ( $(".dropdown-cart").length > 0 || $(".cart-collaterals").length > 0 || $(".cart_totals ").length > 0 ) ) $.ajax({ type: 'POST', dataType: "json", async: true, url: ajax_resurs_object.baseDir, data: 'action=ResursBankAjaxResponse&method=getCostOfPurchase&rbmpass=' + ajax_resurs_object.rbmpass, success: function (json) { if (json.success) { var $costofpurchase = $(json.costofpurchase); var clone = $costofpurchase.clone(); if ($(".cart-totals-inner").length > 0) { $costofpurchase.appendTo(".cart-totals-inner"); } else if ($(".cart_totals ").length > 0) { $costofpurchase.appendTo(".cart_totals"); } if ($(".dropdown-cart").length > 0) { console.log("clone added"); clone.appendTo(".dropdown-cart"); } // $costofpurchase.appendTo(".cart-collaterals"); bindRBpopup('.RBsummary'); RBsummaryloading = false; } else { // no data } } }); })(jQuery); } function getProductCostOfPurchaseOneByOne(price) { if (typeof(price)!='undefined' && !isNaN(price)) { var key = price.toString().replace(".", "_"); prices[key] = price; if (typeof prices_html[key] == 'undefined') { jQuery.ajax({ type: 'POST', dataType: "json", async: true, cache: true, url: ajax_resurs_object.baseDir, data: 'action=ResursBankAjaxResponse&method=getProductCostOfPurchase&price=' + price + '&rbmpass=' + ajax_resurs_object.rbmpass, success: function (json) { // console.log(json); if (json.success) { jQuery('.rbpricetag.pricechanged[data-price="' + price + '"]').each(function () { var rbpricetag = jQuery(this); if (json.costofpurchase != '') { rbpricetag.html(json.costofpurchase); bindRBpopup('.pricechanged .RBproduct'); rbpricetag.removeClass('pricechanged'); } }); } else { // no data } } }); } else { jQuery('.rbpricetag.pricechanged[data-price="' + price + '"]').each(function () { var rbpricetag = jQuery(this); rbpricetag.html(prices_html[key]); bindRBpopup('.pricechanged .RBproduct'); rbpricetag.removeClass('pricechanged'); }); } } } function getProductCostOfPurchase() { (function ($) { if (RBproductloading === false) { RBproductloading = true; $('.rbpricetag.pricechanged').each(function () { key = $(this).attr('data-price').replace(".", "_"); prices[key] = $(this).attr('data-price'); }); $.each(prices, function (index, value) { var price = value; if (!isNaN(price) && price > 0) { $.ajax({ type: 'POST', dataType: "json", async: true, cache: true, url: ajax_resurs_object.baseDir, data: 'action=ResursBankAjaxResponse&method=getProductCostOfPurchase&price=' + price + '&rbmpass=' + ajax_resurs_object.rbmpass, success: function (json) { // console.log(json); if (json.success) { $('.rbpricetag.pricechanged[data-price="' + price + '"]').each(function () { var rbpricetag = $(this); if (json.costofpurchase != '') { rbpricetag.html(json.costofpurchase); bindRBpopup('.pricechanged .RBproduct'); rbpricetag.removeClass('pricechanged'); } }); } else { // no data } } }); } }); RBproductloading = false; } })(jQuery); } function getPlacementFunction(defaultPosition, width, height) { (function ($) { return function (tip, element) { var position, top, bottom, left, right; var $element = $(element); var boundTop = $(document).scrollTop(); var boundLeft = $(document).scrollLeft(); var boundRight = boundLeft + $(window).width(); var boundBottom = boundTop + $(window).height(); var pos = $.extend({}, $element.offset(), { width: element.offsetWidth, height: element.offsetHeight }); var isWithinBounds = function (elPos) { return boundTop < elPos.top && boundLeft < elPos.left && boundRight > (elPos.left + width) && boundBottom > (elPos.top + height); }; var testTop = function () { if (top === false) return false; top = isWithinBounds({ top: pos.top - height, left: pos.left + pos.width / 2 - width / 2 }); return top ? "top" : false; }; var testBottom = function () { if (bottom === false) return false; bottom = isWithinBounds({ top: pos.top + pos.height, left: pos.left + pos.width / 2 - width / 2 }); return bottom ? "bottom" : false; }; var testLeft = function () { if (left === false) return false; left = isWithinBounds({ top: pos.top + pos.height / 2 - height / 2, left: pos.left - width }); return left ? "left" : false; }; var testRight = function () { if (right === false) return false; right = isWithinBounds({ top: pos.top + pos.height / 2 - height / 2, left: pos.left + pos.width }); return right ? "right" : false; }; switch (defaultPosition) { case "top": if (position = testTop()) return position; case "bottom": if (position = testBottom()) return position; case "left": if (position = testLeft()) return position; case "right": if (position = testRight()) return position; default: if (position = testTop()) return position; if (position = testBottom()) return position; if (position = testLeft()) return position; if (position = testRight()) return position; return defaultPosition; } } })(jQuery); }; // source --> https://naturliggas.dk/wp-content/plugins/gp-premium/woocommerce/functions/js/woocommerce.min.js?ver=1.5.6 jQuery(document).ready(function(a){a(".wc-has-gallery .wc-product-image").hover(function(){a(this).find(".secondary-image").css("opacity","1")},function(){a(this).find(".secondary-image").css("opacity","0")})});